<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>详情页</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="../css/qt/nav.css">
    <link rel="stylesheet" href="../css/qt/list.css">
    <link rel="stylesheet" href="../css/qt/show.css">
    <script src="../JS/jquery-1.12.4.js"></script>
</head>
<body>
<?php
require ('../qt/common/list_nav.php');
?>
<?php
error_reporting(0);
mysql_connect("localhost","root","1161105403");
mysql_select_db("blog");
mysql_query("set names utf8");
//连接数据库
session_start();
//类型id是通过GET方法提交的
//根据类型vid从数据库中查询某个特定视频信息
$bid = $_GET['bid'];
$sql="select * from blogs where bid=$bid";
//echo $sql;
$result = mysql_query($sql) or die('查询1失败！'.mysql_error());
$row = mysql_fetch_assoc($result);
//取得留言分页记录
//获取指定的页码
//判断是否指定第几页，如果没有指定，则显示第1页。
if(!isset($_GET["page"]))
    $page=1;
else{
    $page=$_GET["page"];
}
//获取总行数，用于计算分几页显示
$sql0="select * from comments where bid=$bid";
$result0 = mysql_query($sql0);
$totalrows = mysql_num_rows($result0);
//定义每页显示的行数
$rowsperpage =5;
//计算从表中第几行开始输出
$start = ($page-1) * $rowsperpage;
//查询用户，从第$start行开始，共查询$rowsperpage行。
$sql0.= " limit {$start}, {$rowsperpage}";
// echo $sql0.'<br/>';
//执行sql语句
$result0= mysql_query($sql0) or die('查询2失败！'.mysql_error());
//更新点击量
$visit=$row["visited"]+1;
$sql2="update blogs set visited=$visit where bid=$bid";
mysql_query($sql2) or die('查询3失败！'.mysql_error());
?>
<div class="col-md-4 text-center">
    <img src="../images/blog/<?php
    echo $row["pic"];
    ?>
                  " width="200" height="250">
    <!-- 点击标题显示新窗口中的视频-->
    <div class="theme-buy">
        <a class="theme-login" href="javascript:;">
            <h3 class="brand-name" title="点击这里可在线播放~"><?php
                echo $row["title"];
                ?><img src="assets/images/play.png" width="30px" height="30px">
            </h3></a>
    </div>
    <div class="theme-popover">
        <div class="theme-poptit">
            <a  href="javascript:;" title="关闭" class="close">×</a>
            <h4><?php
                echo $row["title"];
                ?> </h4>
        </div>
        <div>
            <video id="myVideo" src=<?php
            echo $row["address"];
            ?> controls  width="100%" height="100%"></video>
        </div>
    </div>
    <div class="theme-popover-mask"></div>

    <!-- 显示总评分-->
    <ul class="list-inline row text-center">
        <?php
        $sqls="select avg(evaluate) from assess where bid=$bid";
        $query=mysql_query($sqls) or die('查询4失败！'.mysql_error());
        while($row1=mysql_fetch_array($query))
        {
            $number= $row1['0'];
            $p= stripos($number, '.');
//echo substr($number,0,$p+2);
            if($number==0)
                echo" <li><h4>影片评分：暂无评分";
            else
                echo" <li><h4>影片评分：</h4></li>".substr($number,0,$p+2);
        }
        ?>
    </ul>
    <!-- 显示总评分 结束-->
</div>
<div class="col-md-8 text-center">
    <table class="table">
        <tr>
            <td>专栏</td>
            <td><?php
                $tid=$row["tid"];
                $sqlt="select * from blogtype where tid=$tid";
                $result=mysql_query($sqlt) or die('查询5失败！'.mysql_error());
                $vname=mysql_fetch_assoc($result);
                echo $vname["blogtype"];
                ?>
            </td>
        </tr>
        <tr>
            <td>上传时间</td>
            <td><?php
                echo $row["uploaddate"];
                ?>
            </td>
        </tr>
        <tr>
            <td>点击次数</td>
            <td><?php
                echo $row["visited"];;
                ?>
            </td>
        </tr>
        <tr>
            <td>上传人</td>
            <td>
                <?php
                $adminid=$row["uploadadmin"];
                $adminrs=mysql_query("select * from admins where adminid=$adminid");
                $admin=mysql_fetch_assoc($adminrs);
                echo $admin["adminname"];
                ?>
            </td>
        </tr>
        <tr>
            <td>下载次数</td>
            <td> <?php
                echo $row["visited"];
                ?>
            </td>
        </tr>
        <tr>
            <td>有事找站长</td>
            <td><a href="mailto:zhouhaibo@neusoft.edu.cn">意见箱</a>
            </td>
        </tr>
        <tr>
            <td>下载地址</td>
            <td> <a href="down.php?bid=<?php
                echo $row["bid"];?>" >点击这里下载</a>
            </td>
        </tr>
        <tr>
            <td>评分</td>
            <td>
                <?php
                //登录后的用户才可以评分
                if(isset($_SESSION["user"]))
                {
                    ?>
                    <form name="f1" method="get" action="doLevel.php" onsubmit="check()" class="form-horizontal">
                        <input type="hidden"name="bid" value="<?php
                        echo $row["bid"];
                        ?>">
                        <select  name="level" required>
                            <option selected value="">评价影片</option>
                            <option value="5">力推★★★★★</option>
                            <option value="4">推荐★★★★</option>
                            <option value="3">还行★★★</option>
                            <option value="2">较差★★</option>
                            <option value="1">很差★</option>
                        </select>
                        <input type="submit" value=" 评价">
                    </form>
                    <?php
                }else{
                    ?>
                    <h3 ><a href="#" data-toggle="modal" data-target="#login"  onclick="func(<?php
                        echo $row['bid']
                        ?>)">登录</a>后可以评分</h3>
                    <?php
                }
                ?>
            </td>
        </tr>
    </table>
</div>
<!-- 从show页登录成功后取得vid 并跳转到登录模态框-->
<script>
    function func(bid){
        document.getElementById("videoid").value=bid;
        document.getElementById("login").modal();
    }
</script>
<div class="col-lg-12">
    <h3 class="intro-text text-center">内容简介</h3>
    <?php
    echo $row["intro"];
    ?>
</div>
<?php
//如果有留言显示留言列表
$num=mysql_num_rows($result0);
if($num>0)
{
    ?>
    <div class="row box">
        <div class="col-md-12">
            <h3 class="intro-text text-center">留言列表</h3>
            <table class="table" align="center">
                <tr>
                    <th>序号</th>
                    <th>内容</th>
                    <th>评论人</th>
                    <th>发表时间</th>
                </tr>
                <?php
                $i=1;
                while($row=mysql_fetch_assoc($result0))
                {
                    ?>
                    <tr>
                        <td width="10%"><?php
                            echo $i++;
                            ?>
                        </td>
                        <td width="50%"><?php
                            echo $row["content"];
                            ?>
                        </td>
                        <td width="20%"><?php
                            $uid=$row["uid"];
                            $userrs=mysql_query("select * from users where uid=$uid");
                            $user=mysql_fetch_assoc($userrs);
                            echo $user["uname"];
                            ?>
                        </td>
                        <td width="20%"><?php
                            echo $row["cdate"];
                            ?>
                        </td>
                    </tr>
                    <?php
                }//end of while
                ?>
            </table>
            <div align="center">

                <!-- <?php
                // 此处略去显示分页页码超链接的代码
                ?> -->
            </div>
        </div>
    </div>
    <?php
}//end of if
else{
    ?>
    <div class="row box">
        <div class="col-md-12">
            <h3 class="intro-text text-center">暂无留言</h3>
        </div>
    </div>
    <?php
}
?>
<?php
session_start();
if(isset($_SESSION["user"]))
{
    ?>
    <div class="row box">
        <div class="col-md-12">
            <h3 class="intro-text text-center">您的留言</h3>
            <form method="post" action="doComment.php" class="form-horizontal">
                <input type="hidden" name="bid" value=<?php echo $bid ?>>
                <div class="form-group">
                    <div class="col-md-12">
                        <textarea class="form-control" cols="80" rows="10"  required name="content"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-12 text-center">
                        <input type="submit" class="btn btn-default" value="发表留言">
                    </div>
                </div>
            </form>
        </div>
    </div>
    <?php
}else{
    ?>
    <div class="row box">
        <div class="col-lg-12" style="align:center;">
            <h3 ><a href="#" data-toggle="modal" data-target="#login"  onclick="func(<?php
                echo $row['bid']
                ?>)">登录</a>后可以发表留言</h3>
        </div>
    </div>
    <?php
}
?>

</body>
</html>